package org.jeecg.modules.api.controller;

import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.config.wlhy.AipOcrClient;
import org.jeecg.config.wlhy.AmapClient;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.io.IOException;

@Api(tags = "Amap")
@RestController
@RequestMapping("/amap")
@Slf4j
public class AmapController {

    @Resource
    AmapClient amapClient;


    /**
     * ip地址
     *
     * @param ip
     * @return
     */
    @AutoLog(value = "amap-ip地址")
    @ApiOperation(value = "amap-ip地址", notes = "amap-ip地址")
    @GetMapping(value = "/ip")
    public Result<JSONObject> ip(@RequestParam String ip) {
        try {
            JSONObject jsonObject = amapClient.ip(ip);
            log.info("amap-ip地址 {}", jsonObject);
            return Result.OK(jsonObject);
        } catch (IOException e) {
            throw new RuntimeException(e.getMessage());
        }
    }

}
